﻿using System.Diagnostics.Contracts;
using System.Threading.Tasks;

namespace DaveSexton.Labs
{
	/// <summary>
	/// Represents an individual experiment.
	/// </summary>
	[ContractClass(typeof(IExperimentContract))]
	public interface IExperiment
	{
		/// <summary>
		/// Gets the name of the experiment.
		/// </summary>
		string DisplayName { get; }

		/// <summary>
		/// Gets a brief textual description of the experiment.
		/// </summary>
		string Description { get; }

		/// <summary>
		/// Asynchronously executes the experiment.
		/// </summary>
		/// <returns>A <see cref="Task"/> representing the asynchronously executing experiment.</returns>
		Task ExecuteAsync();
	}

	[ContractClassFor(typeof(IExperiment))]
	internal abstract class IExperimentContract : IExperiment
	{
		public string DisplayName
		{
			get
			{
#if !WINDOWS_PHONE_70
				Contract.Ensures(!string.IsNullOrWhiteSpace(Contract.Result<string>()));
#else
				Contract.Ensures(!string.IsNullOrEmpty(Contract.Result<string>()));
#endif
				return null;
			}
		}

		public string Description
		{
			get
			{
				Contract.Ensures(Contract.Result<string>() != null);
				return null;
			}
		}

		public Task ExecuteAsync()
		{
			return null;
		}
	}
}